using JGSY.CMS.LowCode.Platform.Application.Interfaces;
using JGSY.CMS.LowCode.Platform.Application.DTOs;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace JGSY.CMS.LowCode.Platform.Controllers
{
    /// <summary>
    /// 风险评估管理接口。
    /// 提供风险评估创建、查询、删除，以及评估结果管理等相关功能的 API。
    /// </summary>
    [ApiController]
    [Route("api/[controller]")]
    public class RiskAssessmentController : ControllerBase
    {
        /// <summary>
        /// 风险评估应用服务接口
        /// </summary>
        private readonly IRiskAssessmentAppService _service;
        
        /// <summary>
        /// 构造函数，注入风险评估服务
        /// </summary>
        /// <param name="service">风险评估应用服务接口</param>
        public RiskAssessmentController(IRiskAssessmentAppService service)
        {
            _service = service;
        }
        /// <summary>
        /// 计算风险评估得分
        /// </summary>
        /// <param name="context">风险评估上下文数据传输对象</param>
        /// <returns>风险评估结果</returns>
        [HttpPost("calculate")]
        public async Task<ActionResult<RiskAssessmentResultDto>> Calculate([FromBody] RiskAssessmentContextDto context)
        {
            var result = await _service.CalculateRiskScoreAsync(context);
            return Ok(result);
        }
    }
}
